package com.xhapi.controller;

import com.xhapi.pojo.dto.PPTCreatorDTO;
import com.xhapi.pojo.entity.ApiResult;
import com.xhapi.service.PPTCreatorService;
import com.xhapi.utils.ApiResultHandler;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import java.io.IOException;

@RestController
@CrossOrigin
@RequestMapping("/ppt_create")
@RequiredArgsConstructor
@Slf4j
public class PPTCreatorController {
    private final PPTCreatorService pptCreatorService;
    /*
    * 接收参数说明
    * query 用户生成PPT要求，最多8K字|create_model，PPT生成类型，一般使用默认的auto|theme，PPT的主题名|author，PPT的作者名
    * 详情参考https://www.xfyun.cn/doc/spark/PPTGeneration.html#%E6%8E%A5%E5%8F%A3%E5%88%97%E8%A1%A8
    * */
    @PostMapping
    public ApiResult createPPT(@RequestBody PPTCreatorDTO dto) throws IOException, InterruptedException {
        return ApiResultHandler.success(pptCreatorService.createPPTByInput(dto));
    }
}
